<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
    <title>注册帐号</title>
    <link rel="shortcut icon" href="assets/img/favicon.png">
    <link rel="stylesheet" href="__HOME__/static/home/css/bootstrap.min.css">
    <link rel="stylesheet" href="__HOME__/static/home/css/style-no.css">
</head>
<body>

<!-- Main Wrapper -->
<div class="main-wrapper login-body">

    <div class="login-wrapper">
        <div class="container">
            <img class="img-fluid logo-dark mb-2" src="__HOME__/static/index/img/logo.png" alt="Logo">

            <div class="loginbox">
                <div class="login-right">
                    <div class="login-right-wrap">
                        <h1>注册</h1>
                        <p class="account-subtitle">享用更多的功能</p>

                        <!-- Form -->
                        <form id="oreoDataAddForm" action="" method="post">
                            <div class="form-group">
                                <label class="form-control-label"><a id="target_name"> </a></label>
                                <input class="form-control" type="text" name="is_target">
                            </div>
                            <div class="form-group">
                                <label class="form-control-label">密码</label>
                                <input class="form-control" type="text" name="password">
                            </div>
                            <div class="form-group">
                                <label class="form-control-label">验证码</label>
                                <input type="text" name="local_verify_code" id="local_verify_code" class="form-control verifyCode" placeholder="请输入后面数字验证码" style="background:url('register/captcha') no-repeat right;background-size:100px 50px;">
                            </div>

                            <div class="input-group" style="height: 4em;">
                                <input type="text" name="verifyCode" class="form-control" placeholder="请输入验证码">
                                <span class="input-group-btn">
                          <button class="btn btn-info" type="button" onclick="sms()" id="btn_send">获取验证码</button>
                        </span>
                            </div>

                            <div class="form-group mb-0">
                                <button class="btn btn-lg btn-block btn-primary" type="button" onclick="shortDomain()">注册</button>
                            </div>
                        </form>
                        <!-- /Form -->
                        <div class="text-center dont-have">已经有帐号? <a href="login.html">登录</a></div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>
<!-- /Main Wrapper -->

<!-- jQuery -->
<script src="__HOME__/static/layuiadmin/jquery.min.js"></script>
<script src="__HOME__/static/index/js/sweetalert.min.js"></script>
<script>
    let trg_name = {$system_sms};
    if(trg_name == 1){
        $("#target_name").html('邮箱');
    }else{
        $("#target_name").html('手机号码');
    }
    //倒计时60秒
    let countdown=60;
    //显示获取验证码倒计时的文本标签
    let _generate_code =$("#btn_send");
    //验证码重新获取倒计时
    function settime() {
        if (countdown == 0) {
            _generate_code.attr("disabled",false);
            $("#btn_send").html("重新获取");
            countdown = 60;
            return false;
        } else {
            _generate_code.attr("disabled", true);
            $("#btn_send").html("已发送(" + countdown + ")");
            countdown--;
        }
        setTimeout(function() {
            settime();
        },1000);
    }
    function sms(){
        $.ajax({
            type: "POST",
            url:'{fun:ctr("regUser")}',
            data: $('#oreoDataAddForm').serialize() +"&"+"sms_type=1" ,
            dataType: 'json',
            success : function(res) {
                if(res.code == 200){
                    settime();
                    swal("执行成功", res.msg, {
                        icon: "success",
                    })
                } else {
                    return swal("发生错误!", res.msg, "error");
                }
            }
        });
    }
    function shortDomain(){
        $.ajax({
            type: "POST",
            url:'{fun:ctr("regUser")}',
            data: $('#oreoDataAddForm').serialize(),
            dataType: 'json',
            success : function(res) {
                if(res.code == 200){
                    swal("注册成功", {
                        icon: "success",
                    }).then(function () {
                        window.setTimeout(function () {
                            top.location = '{fun:ctr("../Login")}';
                        }, 1000);
                    });
                } else {
                    return swal("发生错误!", res.msg, "error");
                }
            }
        });
    }
</script>
</body>
</html>